package com.maxmlr.music.common.config;

import com.google.common.collect.Maps;
import org.springframework.boot.web.servlet.FilterRegistrationBean;

import java.util.Map;

/**
 * @ClassName XssConfig
 * @Description TODO
 * @Author maxiao
 * @Date 2020/6/5 下午4:18
 * @Version V1.0
 */
//@Configuration
public class XssConfig{

    /**
     * xss过滤拦截器
     */
//    @Bean
    public FilterRegistrationBean xssFilterRegistrationBean() {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(new XssFilter());
        filterRegistrationBean.setOrder(1);
        filterRegistrationBean.setEnabled(false);
        filterRegistrationBean.addUrlPatterns("/*");
        Map<String, String> initParameters = Maps.newHashMap();
        initParameters.put("excludes", "/favicon.ico,/img/*,/js/*,/css/*");
        initParameters.put("isIncludeRichText", "true");
        filterRegistrationBean.setInitParameters(initParameters);
        return filterRegistrationBean;
    }
}
